# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Manolis Tzanidakis <manolis@archlinux.org>

pkgname=libieee1284
pkgver=0.2.11
_tag=${pkgver//\./_}
pkgrel=15
pkgdesc="A library to query devices connected in parallel port"
arch=('loong64' 'x86_64')
license=('GPL2')
url="https://github.com/twaugh/libieee1284"
optdepends=('python: for python module')
makedepends=('python' 'xmlto' 'docbook-xml' 'docbook-xsl')
source=(libieee1284-$pkgver.zip::https://github.com/twaugh/libieee1284/archive/V$_tag.zip
        upstream_python_fix1.patch
        upstream_python_fix2.patch
        python3.patch)
sha256sums=('9c3208730fe7a1cefc06e252f4b579685a9e0942ccf0a9cd617810198c8112a4'
            'a0b46ccba73b4e691a001d3bd1a6f4046c5fa26244fcdc3dc10c8baa9886e57f'
            'c63d207205af43d3413e0e969771163185ab27cc1dde07577fec13f344d9d053'
            '9009783b521e53bde4e1f2f291e9ebb0db57e821c9cdf20c21b937a3f4308d42')

prepare() {
  cd $pkgname-$_tag

  patch -p1 < ../upstream_python_fix1.patch # https://github.com/twaugh/libieee1284/commit/c48855528beee1397d883f9c8a5df7aed5c917a6
  patch -p1 < ../upstream_python_fix2.patch # https://github.com/twaugh/libieee1284/commit/b4d63327dfef8dbf12aabf4bba0f6818a3519995

  patch -p1 < ../python3.patch # https://github.com/twaugh/libieee1284/issues/4
}

build() {
  cd $pkgname-$_tag

  ./bootstrap
  ./configure --prefix=/usr --mandir=/usr/share/man --with-python
  make
}

package() {
  cd $pkgname-$_tag
  make DESTDIR="$pkgdir"/ install
}
